import request from '@/utils/request'
import type { Trademark, TrademarkListResponse } from './type';
enum API {
    // 获取品牌列表
    TRADEMARK_URL = '/admin/product/baseTrademark',
    // 添加品牌
    ADD_TRADEMARK_URL = '/admin/product/baseTrademark/save',
    // 修改品牌
    UPDATE_TRADEMARK_URL = '/admin/product/baseTrademark/update',
    // 删除品牌
    DELETE_TRADEMARK_URL = '/admin/product/baseTrademark/remove',
}

export const getTrademarkList = (page: number, limit: number) => request.get<any, TrademarkListResponse>(API.TRADEMARK_URL + `/${page}/${limit}`)
// 添加品牌
export const addTrademarkOrUpdate = (data: Trademark) => {
    if (data.id) {
        console.log(data);
        return request.put<any, any>(API.UPDATE_TRADEMARK_URL, data)
    } else {
        console.log('b');
        return request.post<any, any>(API.ADD_TRADEMARK_URL, data)
    }
}
// 删除品牌
export const deleteTrademark = (id: number) => request.delete<any, any>(API.DELETE_TRADEMARK_URL + `/${id}`)

